package server;

import java.util.ArrayList;
import java.util.List;

import dao.QueryMoneyDao;
import pojo.RoomDto;

public class QueryMoneyServer {
	public List<String> getPreMoney(String roomNum,String preDay){
		QueryMoneyDao queryMoney = new QueryMoneyDao();
		List<RoomDto> roomList = queryMoney.queryRoomByNum(roomNum);
		if(roomList.size() == 0){
			return null;
		}
		if(roomList.get(0).status.equals("1")){
			return null;
		}
		List<String> rateList = queryMoney.queryRateByMoney(roomList.get(0).money);
		if(rateList.size()==0){
			return null;
		}
		int parPay = Integer.parseInt(rateList.get(0));
		int money = Integer.parseInt(roomList.get(0).money);
		int day = Integer.parseInt(preDay);
		
		int sum = parPay + money*(day-1);
		int total = money * day;
		
		String sumString = Integer.toString(sum);
		String totalString = Integer.toString(total);
		
		System.out.println("sum"+sumString+"total"+totalString);
		
		List<String> list = new ArrayList<String>();
		list.add(sumString);
		list.add(totalString);
		return list;
		
		
	}
}
